-
-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed performance issue #7854 #7858
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -36,6 +36,8 @@ | |||||||||||
#include "../common/os/os_utils.h" | ||||||||||||
#include "unicode/ucal.h" | ||||||||||||
|
||||||||||||
#include <atomic> | ||||||||||||
|
||||||||||||
using namespace Firebird; | ||||||||||||
|
||||||||||||
namespace | ||||||||||||
|
@@ -45,8 +47,19 @@ namespace | |||||||||||
public: | ||||||||||||
TimeZoneDesc(MemoryPool& pool) | ||||||||||||
: asciiName(pool), | ||||||||||||
unicodeName(pool) | ||||||||||||
unicodeName(pool), | ||||||||||||
calendar(nullptr) | ||||||||||||
{ | ||||||||||||
} | ||||||||||||
|
||||||||||||
~TimeZoneDesc() | ||||||||||||
{ | ||||||||||||
UCalendar* val = calendar.exchange(nullptr); | ||||||||||||
if (val) | ||||||||||||
{ | ||||||||||||
auto& icuLib = Jrd::UnicodeUtil::getConversionICU(); | ||||||||||||
icuLib.ucalClose(val); | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
public: | ||||||||||||
|
@@ -70,9 +83,26 @@ namespace | |||||||||||
return unicodeName.begin(); | ||||||||||||
} | ||||||||||||
|
||||||||||||
UCalendar* getCalendar(const Jrd::UnicodeUtil::ConversionICU& icuLib, UErrorCode* err) const | ||||||||||||
{ | ||||||||||||
UCalendar* val = calendar.load(); | ||||||||||||
if (!val) | ||||||||||||
{ | ||||||||||||
val = icuLib.ucalOpen(getUnicodeName(), -1, NULL, UCAL_GREGORIAN, err); | ||||||||||||
if (!val) | ||||||||||||
return val; | ||||||||||||
|
||||||||||||
UCalendar* old = calendar.exchange(val); | ||||||||||||
if (old) | ||||||||||||
return old; | ||||||||||||
} | ||||||||||||
return icuLib.ucalClone(val, err); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About performance, with patch I have following result:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "However, you cannot use a reference to an open service object in two threads at the same time if either of them calls any non-const API."
In no place it says There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, the full cite is:
|
||||||||||||
} | ||||||||||||
|
||||||||||||
private: | ||||||||||||
string asciiName; | ||||||||||||
Array<UChar> unicodeName; | ||||||||||||
mutable std::atomic<UCalendar*> calendar; | ||||||||||||
}; | ||||||||||||
} | ||||||||||||
|
||||||||||||
|
@@ -593,8 +623,7 @@ void TimeZoneUtil::extractOffset(const ISC_TIMESTAMP_TZ& timeStampTz, SSHORT* of | |||||||||||
|
||||||||||||
Jrd::UnicodeUtil::ConversionICU& icuLib = Jrd::UnicodeUtil::getConversionICU(); | ||||||||||||
|
||||||||||||
UCalendar* icuCalendar = icuLib.ucalOpen( | ||||||||||||
getDesc(timeStampTz.time_zone)->getUnicodeName(), -1, NULL, UCAL_GREGORIAN, &icuErrorCode); | ||||||||||||
UCalendar* icuCalendar = getDesc(timeStampTz.time_zone)->getCalendar(icuLib, &icuErrorCode); | ||||||||||||
|
||||||||||||
if (!icuCalendar) | ||||||||||||
status_exception::raise(Arg::Gds(isc_random) << "Error calling ICU's ucal_open."); | ||||||||||||
|
@@ -702,8 +731,7 @@ void TimeZoneUtil::localTimeStampToUtc(ISC_TIMESTAMP_TZ& timeStampTz) | |||||||||||
|
||||||||||||
Jrd::UnicodeUtil::ConversionICU& icuLib = Jrd::UnicodeUtil::getConversionICU(); | ||||||||||||
|
||||||||||||
UCalendar* icuCalendar = icuLib.ucalOpen( | ||||||||||||
getDesc(timeStampTz.time_zone)->getUnicodeName(), -1, NULL, UCAL_GREGORIAN, &icuErrorCode); | ||||||||||||
UCalendar* icuCalendar = getDesc(timeStampTz.time_zone)->getCalendar(icuLib, &icuErrorCode); | ||||||||||||
|
||||||||||||
if (!icuCalendar) | ||||||||||||
status_exception::raise(Arg::Gds(isc_random) << "Error calling ICU's ucal_open."); | ||||||||||||
|
@@ -771,8 +799,7 @@ bool TimeZoneUtil::decodeTimeStamp(const ISC_TIMESTAMP_TZ& timeStampTz, bool gmt | |||||||||||
#endif | ||||||||||||
Jrd::UnicodeUtil::ConversionICU& icuLib = Jrd::UnicodeUtil::getConversionICU(); | ||||||||||||
|
||||||||||||
UCalendar* icuCalendar = icuLib.ucalOpen( | ||||||||||||
getDesc(timeStampTz.time_zone)->getUnicodeName(), -1, NULL, UCAL_GREGORIAN, &icuErrorCode); | ||||||||||||
UCalendar* icuCalendar = getDesc(timeStampTz.time_zone)->getCalendar(icuLib, &icuErrorCode); | ||||||||||||
|
||||||||||||
if (!icuCalendar) | ||||||||||||
status_exception::raise(Arg::Gds(isc_random) << "Error calling ICU's ucal_open."); | ||||||||||||
|
@@ -1067,7 +1094,7 @@ TimeZoneRuleIterator::TimeZoneRuleIterator(USHORT aId, const ISC_TIMESTAMP_TZ& a | |||||||||||
{ | ||||||||||||
UErrorCode icuErrorCode = U_ZERO_ERROR; | ||||||||||||
|
||||||||||||
icuCalendar = icuLib.ucalOpen(getDesc(id)->getUnicodeName(), -1, NULL, UCAL_GREGORIAN, &icuErrorCode); | ||||||||||||
icuCalendar = getDesc(id)->getCalendar(icuLib, &icuErrorCode); | ||||||||||||
|
||||||||||||
if (!icuCalendar) | ||||||||||||
status_exception::raise(Arg::Gds(isc_random) << "Error calling ICU's ucal_open."); | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd get icuLib here instead of receive by argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered it first, but then found that
icuLib
is already present at all points wheregetCalendar()
is used.