Skip to content

Commit ee357c9

Browse files
committed
Fix #7759 - Routine calling overhead increased by factor 6 vs Firebird 4.0.0.
1 parent 9ca903c commit ee357c9

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/jrd/req.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,15 @@ class jrd_req : public pool_alloc<type_req>
174174
void invalidate()
175175
{
176176
gmtTimeStamp.invalidate();
177+
localTimeStampValid = localTimeValid = false;
177178
}
178179

179180
ISC_TIMESTAMP getLocalTimeStamp(USHORT currentTimeZone) const
180181
{
181182
fb_assert(!gmtTimeStamp.isEmpty());
182183

183-
if (timeZone != currentTimeZone)
184-
update(currentTimeZone);
184+
if (!localTimeStampValid || timeZone != currentTimeZone)
185+
update(currentTimeZone, true);
185186

186187
return localTimeStamp;
187188
}
@@ -195,7 +196,7 @@ class jrd_req : public pool_alloc<type_req>
195196
void setGmtTimeStamp(USHORT currentTimeZone, ISC_TIMESTAMP ts)
196197
{
197198
gmtTimeStamp = ts;
198-
update(currentTimeZone);
199+
update(currentTimeZone, false);
199200
}
200201

201202
ISC_TIMESTAMP_TZ getTimeStampTz(USHORT currentTimeZone) const
@@ -215,7 +216,7 @@ class jrd_req : public pool_alloc<type_req>
215216
ISC_TIME_TZ timeTz;
216217

217218
if (timeZone != currentTimeZone)
218-
update(currentTimeZone);
219+
update(currentTimeZone, false);
219220

220221
if (localTimeValid)
221222
{
@@ -242,27 +243,33 @@ class jrd_req : public pool_alloc<type_req>
242243
if (gmtTimeStamp.isEmpty())
243244
{
244245
Firebird::TimeZoneUtil::validateGmtTimeStamp(gmtTimeStamp);
245-
update(currentTimeZone);
246+
update(currentTimeZone, false);
246247
}
247248
}
248249

249250
private:
250-
void update(USHORT currentTimeZone) const
251+
void update(USHORT currentTimeZone, bool updateLocalTimeStamp) const
251252
{
252-
localTimeStamp = Firebird::TimeZoneUtil::timeStampTzToTimeStamp(
253-
getTimeStampTz(currentTimeZone), currentTimeZone);
253+
if (updateLocalTimeStamp)
254+
{
255+
localTimeStamp = Firebird::TimeZoneUtil::timeStampTzToTimeStamp(
256+
getTimeStampTz(currentTimeZone), currentTimeZone);
257+
}
258+
259+
localTimeStampValid = updateLocalTimeStamp;
254260
timeZone = currentTimeZone;
255261
localTimeValid = false;
256262
}
257263

258264
private:
259265
Firebird::TimeStamp gmtTimeStamp; // Start time of request in GMT time zone
260266

267+
mutable bool localTimeStampValid; // localTimeStamp calculation is expensive. So is it valid (calculated)?
268+
mutable bool localTimeValid; // localTime calculation is expensive. So is it valid (calculated)?
261269
// These are valid only when !gmtTimeStamp.isEmpty(), so no initialization is necessary.
262270
mutable ISC_TIMESTAMP localTimeStamp; // Timestamp in timeZone's zone
263271
mutable ISC_USHORT timeZone; // Timezone borrowed from the attachment when updated
264272
mutable ISC_TIME localTime; // gmtTimeStamp converted to local time (WITH TZ)
265-
mutable bool localTimeValid; // localTime calculation is expensive. So is it valid (calculated)?
266273
};
267274

268275
// Fields to support read consistency in READ COMMITTED transactions

0 commit comments

Comments
 (0)