Comments (8)
The problem here is that DailyCalendar.GetNextIncludedTimeUtc()
iterates checking every next millisecond whether it would fit the range. Increments could be larger / start position could be calculated more precisely when we know that there's no need for millisecond or even second precision.
from quartznet.
The following calendar configuration crashes on GetNextIncludedTimeUtc
: System.ArgumentOutOfRangeException : The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')
[Test]
public void GetNextIncludedTimeUtc()
{
TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
var weeklyCalendar = new WeeklyCalendar()
{
TimeZone = timeZone,
};
var dailyCalendar = new DailyCalendar(weeklyCalendar, "06:00", "22:00")
{
TimeZone = timeZone,
InvertTimeRange = true,
};
var holidayCalendar = new HolidayCalendar(dailyCalendar)
{
TimeZone = timeZone,
};
holidayCalendar.AddExcludedDate(new DateTime(2024, 2, 19));
holidayCalendar.AddExcludedDate(new DateTime(2024, 5, 27));
holidayCalendar.AddExcludedDate(new DateTime(2024, 6, 19));
holidayCalendar.AddExcludedDate(new DateTime(2024, 7, 4));
holidayCalendar.AddExcludedDate(new DateTime(2024, 9, 2));
holidayCalendar.AddExcludedDate(new DateTime(2024, 10, 14));
holidayCalendar.AddExcludedDate(new DateTime(2024, 11, 11));
holidayCalendar.AddExcludedDate(new DateTime(2024, 11, 28));
holidayCalendar.AddExcludedDate(new DateTime(2024, 12, 25));
var time = new DateTime(2024, 2, 5, 10, 6, 0, DateTimeKind.Utc);
var expected = new DateTime(2024, 2, 5, 14, 0, 0, DateTimeKind.Utc);
var d = holidayCalendar.GetNextIncludedTimeUtc(time); // throws System.ArgumentOutOfRangeException : The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')
d.Should().Be(expected);
}
from quartznet.
Possibly related dotnet/runtime#25075
One hotspot is the calls to TimeZoneInfo.ConvertTime
in a tight loop.
from quartznet.
@al007 Please check if latest 3.x / master branches in repo resolves your issue.
from quartznet.
No, unfortunately, it does not. The example from the 1st post in this thread works even slower now: 20 seconds for .net8 and 50 seconds for net472. However, it does fix the crash for the 2nd example.
from quartznet.
The example you provided should be in the repo, it executes here in about 43ms.
This is from 3.x branch.
Can you please try running.?
dotnet test --filter GetNextIncludedTimeUtc_CrashOriginal2270
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: 43 ms - Quartz.Tests.Unit.dll (net8.0)
from quartznet.
@jafin , this method has two issues: poor performance and a crash. I reported them together because I thought they were related and re-working the algorithm would fix both.
Performance issue happens for the following calendar configuration HolidayCalendar->WeeklyCalendar->DailyCalendar
, see 1st post here. It is not fixed in the 3.x branch. It takes from 20 to 50 seconds as described above.
The crash happens for calendar WeeklyCalendar->DailyCalendar->HolidayCalendar
, see 2nd post here. It is fixed in the 3.x branch and runs fast.
from quartznet.
@al007 Perhaps I am missing something I copied the example, ran the below against 3.x branch, completed in ~20ms
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: 11 ms - Quartz.Tests.Unit.dll (net8.0)
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: 22 ms - Quartz.Tests.Unit.dll (net472)
[Test]
public void GetNextIncludedTimeUtcFirstIssue()
{
TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
var holidayCalendar = new HolidayCalendar()
{
TimeZone = timeZone,
};
holidayCalendar.AddExcludedDate(new DateTime(2024, 2, 19));
holidayCalendar.AddExcludedDate(new DateTime(2024, 5, 27));
holidayCalendar.AddExcludedDate(new DateTime(2024, 6, 19));
holidayCalendar.AddExcludedDate(new DateTime(2024, 7, 4));
holidayCalendar.AddExcludedDate(new DateTime(2024, 9, 2));
holidayCalendar.AddExcludedDate(new DateTime(2024, 10, 14));
holidayCalendar.AddExcludedDate(new DateTime(2024, 11, 11));
holidayCalendar.AddExcludedDate(new DateTime(2024, 11, 28));
holidayCalendar.AddExcludedDate(new DateTime(2024, 12, 25));
var weeklyCalendar = new WeeklyCalendar(holidayCalendar)
{
TimeZone = timeZone,
};
var calendar = new DailyCalendar(weeklyCalendar, "06:00", "22:00")
{
TimeZone = timeZone,
InvertTimeRange = true,
};
var time = new DateTime(2024, 2, 5, 10, 6, 0, DateTimeKind.Utc);
var expected = new DateTime(2024, 2, 5, 14, 0, 0, DateTimeKind.Utc);
var d = calendar.GetNextIncludedTimeUtc(time); // takes 13 seconds to execute!
d.Should().Be(expected);
}
from quartznet.
Related Issues (20)
- LoggingTriggerHistoryPlugin and LoggingJobHistoryPlugin should use StructuredLogging HOT 1
- Wrong PersistentStore is used when creating multiple Schedulers HOT 11
- Option to stop the constant logging of "Batch acquisition of 0 triggers" HOT 2
- Unable to notify TriggerListener(s) while firing trigger (Trigger and Job will NOT be fired!).
- Job re-executing with no reason after redeploy
- Getting lot of exceptions SchedulerError HOT 5
- [Request] RAM Cache Middleware for ADOJobStore
- [Proposal] Change IDriverDelegate to Filter Triggers for Acquisition Based on Job Type
- Quartz scheduler is frozen HOT 1
- In JobStoreTX the current running trigger has state complete.
- The cycle was running incorrectly according to the cron expression HOT 1
- Automatic sql database schema creation HOT 1
- Can not set job data map with oracle
- Loading plugins dynamically
- Error in ChonExpression DayOfWeek pattern
- Lock 'STATE_ACCESS' wrongful returner
- Couldn't rollback ADO.NET connection. Transaction not connected, or was disconnected
- I have two jobs set up daily at 7AM and 5PM. 7 AM job triggers as expected but 5PM Job is not triggering.
- Why does JobDataMap not support generic functions?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quartznet.