Skip to content

Commit

Permalink
Use spawnStartTime instead of spawnerCreationTime
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed Oct 3, 2024
1 parent f8481e1 commit 6ab1b52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ Group::findBestProcessPreferringStickySessionId(unsigned int id) const {
return process;
} else if (bestProcess == nullptr ||
process->generation > bestProcess->generation ||
(process->generation == bestProcess->generation && process->spawnerCreationTime < bestProcess->spawnerCreationTime) ||
(process->generation == bestProcess->generation && process->spawnerCreationTime == bestProcess->spawnerCreationTime && process->busyness() < bestProcess->busyness())
(process->generation == bestProcess->generation && process->spawnStartTime < bestProcess->spawnStartTime) ||
(process->generation == bestProcess->generation && process->spawnStartTime == bestProcess->spawnStartTime && process->busyness() < bestProcess->busyness())
) {
bestProcess = process;
}
Expand All @@ -91,8 +91,8 @@ Group::findBestProcess(const ProcessList &processes) const {

if (bestProcess == nullptr ||
process->generation > bestProcess->generation ||
(process->generation == bestProcess->generation && process->spawnerCreationTime < bestProcess->spawnerCreationTime) ||
(process->generation == bestProcess->generation && process->spawnerCreationTime == bestProcess->spawnerCreationTime && process->busyness() < bestProcess->busyness())
(process->generation == bestProcess->generation && process->spawnStartTime < bestProcess->spawnStartTime) ||
(process->generation == bestProcess->generation && process->spawnStartTime == bestProcess->spawnStartTime && process->busyness() < bestProcess->busyness())
) {
bestProcess = process;
}
Expand All @@ -119,7 +119,7 @@ Group::findBestEnabledProcess() const {
for (unsigned int i = 0; i < size; i++) {
Process *process = enabledProcesses.at(i).get();
unsigned int gen = process->generation;
unsigned long long startTime = process->spawnerCreationTime;
unsigned long long startTime = process->spawnStartTime;
int busyness = enabledProcessBusynessLevels[i];
if (bestProcess == nullptr ||
gen > bestProcess->generation ||
Expand Down
22 changes: 12 additions & 10 deletions src/agent/Core/ApplicationPool/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,9 @@ typedef boost::container::vector<ProcessPtr> ProcessList;
*/
class Process {
public:
static const unsigned int MAX_SOCKETS_ACCEPTING_HTTP_REQUESTS = 3;
friend class Group;

/**
* Time at which the Spawner that created this process was created.
* Microseconds resolution.
*/
unsigned long long spawnerCreationTime;
static const unsigned int MAX_SOCKETS_ACCEPTING_HTTP_REQUESTS = 3;

private:
/*************************************************************
Expand Down Expand Up @@ -146,6 +142,12 @@ class Process {
*/
StaticString codeRevision;

/**
* Time at which the Spawner that created this process was created.
* Microseconds resolution.
*/
unsigned long long spawnerCreationTime;

/** Time at which we started spawning this process. Microseconds resolution. */
unsigned long long spawnStartTime;

Expand Down Expand Up @@ -450,9 +452,9 @@ class Process {
ProcessMetrics metrics;

Process(const BasicGroupInfo *groupInfo, const unsigned int gen, const Json::Value &args)
: spawnerCreationTime(getJsonUint64Field(args, "spawner_creation_time")),
info(this, groupInfo, args),
: info(this, groupInfo, args),
socketsAcceptingHttpRequestsCount(0),
spawnerCreationTime(getJsonUint64Field(args, "spawner_creation_time")),
spawnStartTime(getJsonUint64Field(args, "spawn_start_time")),
spawnEndTime(SystemTime::getUsec()),
type(args["type"] == "dummy" ? SpawningKit::Result::DUMMY : SpawningKit::Result::UNKNOWN),
Expand All @@ -476,9 +478,9 @@ class Process {

Process(const BasicGroupInfo *groupInfo, const unsigned int gen, const SpawningKit::Result &skResult,
const Json::Value &args)
: spawnerCreationTime(getJsonUint64Field(args, "spawner_creation_time")),
info(this, groupInfo, skResult),
: info(this, groupInfo, skResult),
socketsAcceptingHttpRequestsCount(0),
spawnerCreationTime(getJsonUint64Field(args, "spawner_creation_time")),
spawnStartTime(skResult.spawnStartTime),
spawnEndTime(skResult.spawnEndTime),
type(skResult.type),
Expand Down

0 comments on commit 6ab1b52

Please sign in to comment.